;(function(){
  'use strict';
  angular.module('controllers.omdisplay.recAbnormal')
    .controller('diffCountCtrl', diffCountCtrl)
    .controller('diffCountViewCtrl', diffCountViewCtrl);
  
  function diffCountCtrl($scope, COREDATA, DCSelectorService, DCQueryParamService){
    $scope.selector = DCSelectorService.getSelector();
    $scope.date = DCQueryParamService.getDateParam();
    $scope.diffCount = DCQueryParamService.getQueryParam();
    $scope.getDiffCount = DCQueryParamService.diffCountQueryFn;
    $scope.flag = DCQueryParamService.getFlag();
    $scope.exportUrl = COREDATA.FORMPREFIX + 'OMdisplay/reconciliationsAbnormal/diffCountExport';
    $scope.$watch('diffCount.timeType', function(newValue, oldValue){
      if(newValue === oldValue){
        return;
      }
      $scope.date = DCQueryParamService.getDateParam();
    },true);
    
    $scope.$on('formInvalid', function(eo, flag){
      $scope.quarterInvalid = flag;
    });
    
  }

  diffCountCtrl.$inject = ['$scope', 'COREDATA', 'DCSelectorService', 'DCQueryParamService'];

    
  /**
   * 差异数据统计显示控制
   * @param  {Object} $scope 当前控制器作用域,为diffCountCtrl的子级作用域
   */
  function diffCountViewCtrl($scope, DCViewObjService, DCChartObjService, DCExportObjService){

    $scope.viewObj = DCViewObjService.getViewObj();
    $scope.exportObj = DCExportObjService.getExportObj();

    DCChartObjService.initChartObj();
    DCChartObjService.initOptions();

    $scope.tmall = function(){
      $scope.viewObj.showType = '天猫旗舰店';
    };

    $scope.cmall = function(){
      $scope.viewObj.showType = '移动商城';
    };

    $scope.bankATA = function(){
      $scope.viewObj.showType = '银行总对总';
    };
    $scope.consonanceVoice = function(){
      $scope.viewObj.showType = '灵犀语音';
    };
    $scope.valuableCard = function(){
      $scope.viewObj.showType = '有价卡';
    };
  }

  diffCountViewCtrl.$inject = ['$scope', 'DCViewObjService', 'DCChartObjService', 'DCExportObjService'];
})();